<template>
	<div class="mima">
    <el-dialog title="结算安全设置" :visible.sync="log"  width="360px"  :close-on-click-modal="false" :modal-append-to-body="false" :close-on-press-escape="false">
      <div style="margin-bottom: 20px;">
        为了您的结算资金安全，我们新增了安全设置，请您先设置密码</div>



      <div class="t_input_box" style="margin-bottom: 20px;">
      	<el-input class="t_del_com_input" v-model="form.password"  placeholder="请输入密码" show-password></el-input>
      </div>
      <div class="t_input_box" style="margin-bottom: 20px;">
      	<el-input class="t_del_com_input" v-model="form.password2"  placeholder="请输入新密码" show-password></el-input>
      </div>

      <div slot="footer" class="dialog-footer">
        <el-button round @click="log = false">取消</el-button>
        <el-button type="primary" round @click="xiugaimima">确认</el-button>
      </div>
    </el-dialog>
	</div>
</template>

<script>
	export default {
		name: 'mima',
		data() {
			return {
        log:true,
        mobile:"",
        form:{
          password:"",
          password2:"",
          sms_code:""
        },
        codemsg:'获取验证码',
			}
		},
		created() {
      axios.get('/own/system/get').then((response)=>{
      	if (response.data.msg.code == 0) {
          this.mobile = response.data.data.mobile

      	} else {
      		this.$message.error(response.data.msg.info);
      	}
      })
		},
		mounted() {

		},
		methods: {
      xiugaimima:function(){
        if(this.form.password == this.form.password2){

        }else{
          this.$message.error('两次密码不相同，请重新输入');
          return false
        }
        axios.post('/own/order/checkout/password/config',this.form).then((response)=>{
        	if (response.data.msg.code == 0) {
        		this.$message({
        			message: '设置成功',
        			type: 'success'
        		});
            this.log = false
        	} else {
        		this.$message.error(response.data.msg.info);
        	}
        })
      },
      //获取验证码
      getcode(){
        if(this.codemsg=='获取验证码'){
        	this.codemsg = 60
        	var time = setInterval(()=>{
        		if(this.codemsg>0){
        			this.codemsg--
        		}else{
        			this.codemsg = '获取验证码'
        			clearInterval(time)
        		}
        	},1000)

          axios.post('/own/order/checkout/password/code/send').then((response)=>{
          	if (response.data.msg.code == 0) {
          		this.$message({
          			message: '发送成功',
          			type: 'success'
          		});
          	} else {
          		this.$message.error(response.data.msg.info);
          	}
          })
        }else{

        }
      }
		}
	}
</script>


<style scoped>
  .t_get_code{
  	width: 112px;
  	height: 40px;
  	background: #e6efff;

  	border-radius: 25px;
  	text-align: center;
  	line-height: 40px;
  	color: #005AFF;
  	font-size: 14px;
  	cursor: pointer;

  }
</style>
